﻿/***************************************************
//  Copyright (c) Premium Tax Free 2011
/***************************************************/

using System;
using System.Threading;
using System.Windows.Forms;
using PremierTaxFree.PTFLib;
using PremierTaxFree.PTFLib.Data;

namespace PremierTaxFree
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            SQLWorker.Default.Error += OnError;
            SQLWorker.Default.Start(ThreadPriority.Lowest);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
            SQLWorker.Default.Stop();
        }

        public static void OnError(object sender, ThreadExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            DataAccess.InsertMessageAsync(e.Exception.Message, Strings.TransferringService,
                eMessageTypes.Error, e.Exception.StackTrace, false);
        }
    }
}
